$(function(){

    // app下载点击消失
    $(document).on('click', '#download_app .delete', function(){

        $('#download_app').remove();
        return false;

    });


    //轮播图
    var swUl = $('#switcher ul'),
        swLi = swUl.find('li'),
        aSpanBtn = $('.sw_btn span');
        iWidth = swLi.width();

        swUl.css('width', iWidth*swLi.length);
    

    $(document).on('swipeleft', '#switcher', function(){

        doSwitch(-1);

    });

    $(document).on('swiperight', '#switcher', function(){

        doSwitch(1);

    });

    var timer2 = setInterval(function(){
        doSwitch(-1);
    }, 4000);


    function doSwitch(num){
        
        var oLeft = swUl.position().left+num*iWidth;
        swUl.animate({left: oLeft}, 500, function(){

            if (oLeft < -swUl.width()+2*iWidth) {
                swUl.css('left', -iWidth);
            }
            if (oLeft > -iWidth) {
                // alert(1)
                swUl.css('left', -swUl.width()+2*iWidth);
            }    

        });

        var index = -oLeft/iWidth-1;

        if(index == 5){
            index = 0;
        }
        if(index == -1){
            index = 4;
        }

        aSpanBtn.removeClass('active').eq(index).addClass('active');
    }

});












